text.h
unicsv.h
units.h
+ vcf.h
vecs.h
xcsv.h
xmlgeneric.h
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
+#include "vcf.h"
+
#include <cmath> // for fabs
#include <cstdlib> // for abs
#include <QString> // for QString
-#include <QVector> // for QVector
#include <Qt> // for CaseInsensitive
#include "defs.h"
-#include "gbfile.h" // for gbfprintf, gbfputs, gbfclose, gbfopen, gbfile
+#include "gbfile.h" // for gbfprintf, gbfputs, gbfclose, gbfopen
#include "geocache.h" // for Geocache, Geocache::UtfString
-static gbfile* file_out;
-
-static char* vcf_encrypt = nullptr;
-
#define MYNAME "VCF"
-static
-QVector<arglist_t> vcf_args = {
- {
- "encrypt", &vcf_encrypt,
- "Encrypt hints using ROT13", nullptr, ARGTYPE_BOOL, ARG_NOMINMAX, nullptr
- },
-};
-static void
-wr_init(const QString& fname)
+void
+VcfFormat::wr_init(const QString& fname)
{
file_out = gbfopen(fname, "w", MYNAME);
}
-static void
-wr_deinit()
+void
+VcfFormat::wr_deinit()
{
gbfclose(file_out);
}
* Print a possibly empty input string, replacing newlines with escaped
* newlines as we go.
*/
-static void
-vcf_print_utf(const Geocache::UtfString* s)
+void
+VcfFormat::vcf_print_utf(const Geocache::UtfString* s)
{
if (nullptr == s) {
return;
gbfputs(stripped_html, file_out);
}
-static void
-vcf_print(const char* s)
+void
+VcfFormat::vcf_print(const char* s)
{
if (!s) {
return;
gbfputs(cleaned, file_out);
}
-static void
-vcf_print(const QString& s)
+void
+VcfFormat::vcf_print(const QString& s)
{
vcf_print(CSTR(s));
}
-static void
-vcf_disp(const Waypoint* wpt)
+void
+VcfFormat::vcf_disp(const Waypoint* wpt)
{
int lonint = abs((int) wpt->longitude);
int latint = abs((int) wpt->latitude);
gbfprintf(file_out, "\nEND:VCARD\n");
}
-static void
-data_write()
+void VcfFormat::write()
{
- waypt_disp_all(vcf_disp);
+ auto vcf_disp_lambda = [this](const Waypoint* waypointp)->void {
+ vcf_disp(waypointp);
+ };
+ waypt_disp_all(vcf_disp_lambda);
}
-
-
-ff_vecs_t vcf_vecs = {
- ff_type_file,
- { ff_cap_write, ff_cap_none, ff_cap_none},
- nullptr,
- wr_init,
- nullptr,
- wr_deinit,
- nullptr,
- data_write,
- nullptr,
- &vcf_args,
- NULL_POS_OPS
-};
--- /dev/null
+/*
+ Output only format for Vcard format, VCF
+
+ Copyright (C) 2005 Robert Lipe, robertlipe+source@gpsbabel.org
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+*/
+#ifndef VCF_H_INCLUDED_
+#define VCF_H_INCLUDED_
+
+#include <QString> // for QString
+#include <QVector> // for QVector
+
+#include "defs.h"
+#include "format.h" // for Format
+#include "gbfile.h" // for gbfile
+#include "geocache.h" // for Geocache
+
+
+class VcfFormat : public Format
+{
+public:
+ using Format::Format;
+
+ QVector<arglist_t>* get_args() override
+ {
+ return &vcf_args;
+ }
+
+ ff_type get_type() const override
+ {
+ return ff_type_file;
+ }
+
+ QVector<ff_cap> get_cap() const override
+ {
+ return {ff_cap_write, ff_cap_none, ff_cap_none};
+ }
+
+ void wr_init(const QString& fname) override;
+ void write() override;
+ void wr_deinit() override;
+
+private:
+
+ /* Member Functions */
+
+ void vcf_print_utf(const Geocache::UtfString* s);
+ void vcf_print(const char* s);
+ void vcf_print(const QString& s);
+ void vcf_disp(const Waypoint* wpt);
+
+ /* Data Members */
+
+ gbfile* file_out{};
+
+ char* vcf_encrypt = nullptr;
+
+ QVector<arglist_t> vcf_args = {
+ {
+ "encrypt", &vcf_encrypt,
+ "Encrypt hints using ROT13", nullptr, ARGTYPE_BOOL, ARG_NOMINMAX, nullptr
+ },
+ };
+
+};
+#endif // VCF_H_INCLUDED_
#include "subrip.h" // for SubripFormat
#include "text.h" // for TextFormat
#include "unicsv.h" // for UnicsvFormat
+#include "vcf.h" // for VcfFormat
#include "xcsv.h" // for XcsvStyle, XcsvFormat
-#include "googletakeout.h" // for GoogleTakeoutFormat
+#include "googletakeout.h" // for GoogleTakeoutFormat
extern ff_vecs_t geo_vecs;
extern ff_vecs_t mtk_m241_fvecs;
#endif // MAXIMAL_ENABLED
#if MAXIMAL_ENABLED
-extern ff_vecs_t vcf_vecs;
extern ff_vecs_t gtm_vecs;
#if CSVFMTS_ENABLED
extern ff_vecs_t garmin_txt_vecs;
LegacyFormat mtk_m241_ffmt {mtk_m241_fvecs};
#endif // MAXIMAL_ENABLED
#if MAXIMAL_ENABLED
- LegacyFormat vcf_fmt {vcf_vecs};
UnicsvFormat unicsv_fmt;
LegacyFormat gtm_fmt {gtm_vecs};
#if CSVFMTS_ENABLED
#endif // MAXIMAL_ENABLED
#if MAXIMAL_ENABLED
{
- &vcf_fmt,
+ nullptr,
"vcard",
"Vcard Output (for iPod)",
"vcf",
nullptr,
+ &fmtfactory<VcfFormat>
},
{
&unicsv_fmt,